package com.agua.enturno.servicios.impl;

import com.agua.enturno.persistencia.dao.ClienteDAO;
import com.agua.enturno.servicios.ClienteService;
import com.agua.enturno.vista.dto.ClienteDTO;
import com.agua.enturno.vista.dto.TurnoDTO;
import com.agua.enturno.vista.dto.assemblers.ClienteAssembler;
import com.agua.enturno.vista.dto.assemblers.TurnoAssembler;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public class ClienteServiceImpl implements ClienteService {

	private ClienteDAO clienteDAO;
	private ClienteAssembler clienteAssembler;
	private TurnoAssembler turnoAssembler;
	
	
	/*------------------------------------ Public methods ----------------------------------*/

	@Override
	@Transactional
	public ClienteDTO findById(Long id) {
		return clienteAssembler.assemble(clienteDAO.findById(id));
	}
	
	@Override
	@Transactional
	public List<TurnoDTO> findTurnos(Long clienteId) {
		return turnoAssembler.assemble(clienteDAO.findById(clienteId).getTurnos());
	}

	/*--------------------------------------------------------------------------------------*/
	/*---------------------------------- Geters and seters ---------------------------------*/

	public void setClienteDAO(ClienteDAO clienteDAO) {
		this.clienteDAO = clienteDAO;
	}
	
	public void setClienteAssembler(ClienteAssembler clienteAssembler) {
		this.clienteAssembler = clienteAssembler;
	}
	
	public void setTurnoAssembler(TurnoAssembler turnoAssembler) {
		this.turnoAssembler = turnoAssembler;
	}

	/*--------------------------------------------------------------------------------------*/

}
